#ifndef _SYNCHANNEL_H
#define _SYNCHANNEL_H

#include "syncommon.h"
#include "synvoice.h"
#include "synfx.h"
#include "syncompressor.h"

namespace Synth {

class Mixer;
enum {
	MFL_POSITIVE = 0,
	MFL_NEGATIVE = 1,
};

struct Modulation {
	unsigned char input;
	unsigned char output;
	unsigned char amount;
	unsigned char flags;
};	

class Channel {
	enum {
		NUMVOICES = 8
	};
	int flags;
	char controllerValues[128];
	SVFFilter lfilter, rfilter;
	Distorter ldist, rdist;
	LFO lfo;
	chunkware_simple::SimpleCompRms comp;
	Phaser lphaser, rphaser;
public:
	Channel();
	
	char params[cp_NumChannelParams];

	int no;
	int numModulations;
	int lastNote;

	void NoteOn(int key, int vel);
	void NoteOff(int key);
	void ControllerChange(int cont, int value);

	void ResetChannelParameters();
	void DoModulations();

	// Will destroy in buffers.
	void RenderChannelFX(Block leftbufin, Block rightbufin, Block leftOut, Block rightOut);

	void StopGroup(int group);
	float GetParam(int param) const {return (float)params[param] / 127.f;}
};

}  // namespace

#endif